<template>
  <div class="timeline">
    <div
      v-for="(item, index) in items"
      :key="index"
      class="timeline__item"
    >
      <div class="timeline__marker">
        <div class="timeline__dot"></div>
      </div>
      
      <div class="timeline__content">
        <div class="timeline__period">{{ item.period }}</div>
        <h3 class="timeline__title">{{ item.title }}</h3>
        <div class="timeline__subtitle">{{ item.subtitle }}</div>
        <p class="timeline__description">{{ item.description }}</p>
        
        <ul v-if="item.achievements" class="timeline__achievements">
          <li v-for="(achievement, i) in item.achievements" :key="i">
            {{ achievement }}
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script setup>
defineProps({
  items: {
    type: Array,
    required: true
  }
})
</script>

<style lang="scss" scoped>
.timeline {
  position: relative;
  
  &::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
    
    @include respond-to('md') {
      left: 50%;
      transform: translateX(-50%);
    }
  }
  
  &__item {
    position: relative;
    margin-bottom: $spacing-2xl;
    
    @include respond-to('md') {
      width: 50%;
      
      &:nth-child(even) {
        margin-left: 50%;
        
        .timeline__marker {
          left: -32px;
        }
      }
      
      &:nth-child(odd) {
        .timeline__marker {
          right: -32px;
        }
      }
    }
  }
  
  &__marker {
    position: absolute;
    left: 0;
    top: 0;
    
    @include respond-to('md') {
      left: auto;
    }
  }
  
  &__dot {
    width: 40px;
    height: 40px;
    border-radius: $radius-full;
    background: $primary-color;
    border: 4px solid var(--bg-primary);
    box-shadow: 0 0 0 4px var(--border-color);
  }
  
  &__content {
    margin-left: 60px;
    padding: $spacing-lg;
    background: var(--bg-secondary);
    border-radius: $radius-lg;
    @include transition(transform, box-shadow);
    
    &:hover {
      transform: translateY(-4px);
      box-shadow: var(--shadow-lg);
    }
    
    @include respond-to('md') {
      margin-left: 0;
      margin-right: 40px;
      
      .timeline__item:nth-child(even) & {
        margin-right: 0;
        margin-left: 40px;
      }
    }
  }
  
  &__period {
    display: inline-block;
    padding: $spacing-xs $spacing-sm;
    background: $primary-color;
    color: white;
    font-size: $font-size-sm;
    border-radius: $radius-sm;
    margin-bottom: $spacing-sm;
  }
  
  &__title {
    font-size: $font-size-xl;
    margin-bottom: $spacing-xs;
  }
  
  &__subtitle {
    color: var(--text-secondary);
    font-size: $font-size-base;
    margin-bottom: $spacing-md;
  }
  
  &__description {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: $spacing-md;
  }
  
  &__achievements {
    list-style: none;
    
    li {
      position: relative;
      padding-left: $spacing-lg;
      margin-bottom: $spacing-sm;
      color: var(--text-secondary);
      
      &::before {
        content: '✓';
        position: absolute;
        left: 0;
        color: $primary-color;
        font-weight: bold;
      }
    }
  }
}
</style>

